﻿<!DOCTYPE html>

<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<link href="/LiberUI/Style/LiberUI.css" rel="stylesheet" />
<link href="/SiteUI/Base.css" rel="stylesheet" />
<link href="/SiteUI/Register/Register.css" rel="stylesheet" />
<title>天联云-找回密码</title>
<html>

<body>
    <div class="view" id="headBar">
        <div class="row">
            <div class="col-lg-5 col-lg-offset-1" id="siteLogo">

            </div>
            <div class="col-lg-6" id="siteLink">
                <a href="/Index.html">首页</a>
                <a href="/Products.html">采购云协同</a>
                <a href="/BizCase.html">案例</a>
                <a href="/AboutUS.html">关于我们</a>
            </div>
        </div>
    </div>
   
    <div class="view_fix" id="viewRegister">
      
        <div class="row" id="vr-tip">
            您正在申请重置登录密码，请验证您的手机号
        </div>
        <div class="row" id="vr-mphone"> 
            <div class="col-lg-4 col-lg-offset-4">
                <h5>手机号码：</h5>
                <input maxlength="11" id="txbMPhone" placeholder="请输入手机号码"/>
                
            </div>
            <div class="col-lg-4">
                <h5>&nbsp;</h5>
                <div class="inputTip" id="it-phone"></div>
            </div>
        </div>
        <div class="row" id="vr-captcha">
            <div class="col-lg-4 col-lg-offset-4">
                <div class="l-captcha" data-site-key="5721304f6096b88278069a248b9d0a8c" data-width="100%" data-callback=imgValidateEnd id="validator"></div>
                <br />
            </div>
            <div class="col-lg-2 col-lg-offset-4">
                <h5>验证码：</h5>
                <input maxlength="10" id="txbCaptcha" placeholder="请输入收到的验证码" />
                
            </div>
            <div class="col-lg-2" id="btnSendCaptcha">
                <h5>&nbsp;</h5>
                <div class="button">免费获取验证码</div>
            </div>
            <div class="col-lg-4">
                <h5>&nbsp;</h5>
                <div class="inputTip" id="it-captcha"></div>
            </div>
        </div>
        <div class="row" id="vr-acnt">
            <div class="col-lg-4 col-lg-offset-4">
                <h5>登录密码：</h5>
                <input maxlength="30" id="txbPassword" type="password" placeholder="请设置您的登录密码"/>
                <h5>确认密码：</h5>
                <input maxlength="30" type="password" id="txbConfirmPwd" placeholder="请再次输入登录密码"/>
            </div>
            <div class="col-lg-4">
                <h5>&nbsp;</h5>
                <div class="inputTip" id="it-pwd"></div>
                <h5>&nbsp;</h5>
                <div class="inputTip" id="it-confirmpwd"></div>
            </div>
            <div class="col-lg-4 col-lg-offset-4 button btn-big" id="btnResetPwd">
                重置密码
            </div>
        </div>
    </div>
    <div class="view" id="pageFoot">
        
    </div>
    <div id="tplPrompt" style="display:none">
        <div class="prompt_success">
            <div class="p_body">
                <h4>title</h4>
                <span>message</span>
            </div>
        </div>
        <div class="prompt_info">
            <div class="p_body">
                <h4>title</h4>
                <span>message</span>
            </div>
        </div>
        <div class="prompt_err">
            <div class="p_body">
                <h4>title</h4>
                <span>message</span>
            </div>
        </div>
    </div>

    <script src="/LiberUI/Scripts/jquery.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Base.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Action.js"></script>
    <!--<script src="https://static.geetest.com/static/tools/gt.js"></script>-->
    <script src="//captcha.luosimao.com/static/dist/api.js"></script>
    <script src="/SiteUI/res_sobiz.js"></script>
    <script>
        var ForgetPwd = {
            ResetPwd: {
                phone: null,
                captcha: null,
                pass: null
            },
            PhoneFormat: /^1[3,4,5,7,8]{1}[0-9]{9}$/,  //手机号格式验证的正则
            Countdown: 0,//倒计时秒数
            CountdownHandler: null,  //倒计时器
            BtnSendCaptcha: new LiberUI.Button("#btnSendCaptcha>.button"),
            sendCaptcha: function () {
                //检查图形验证
                //var imgV = ForgetPwd.imgValidator.getValidate();
                var imgV = ForgetPwd.imgValidator;
                if (!imgV) {
                    error("错误", "请先完成人机识别认证", 5);
                    return;
                }
                //TODO:检查发送间隔
                if (ForgetPwd.Countdown <= 0 && ForgetPwd.checkPhone() === true) {
                    ForgetPwd.Countdown = 60;
                    ForgetPwd.ResetPwd.phone = $("#txbMPhone").vl();
                    //$.getJSON("/Register/SendCaptcha", { phone: ForgetPwd.ResetPwd.phone, forwhat: "resetpwd", challenge: imgV.geetest_challenge, validate: imgV.geetest_validate, seccode: imgV.geetest_seccode }, ForgetPwd.sendCaptchaEnd);
                    $.getJSON("/Register/SendCaptcha", { phone: ForgetPwd.ResetPwd.phone, forwhat: "resetpwd",validate: imgV}, ForgetPwd.sendCaptchaEnd);
                    ForgetPwd.BtnSendCaptcha.disable();
                    $("#txbCaptcha").focus();
                    ForgetPwd.CountdownHandler = setTimeout(ForgetPwd.countInterval, 1000);
                }
            },
            countInterval: function (ev) {
                if (ForgetPwd.Countdown > 0) {
                    ForgetPwd.Countdown = ForgetPwd.Countdown - 1;
                    ForgetPwd.BtnSendCaptcha.vl("[" + ForgetPwd.Countdown + "]秒后重新获取");
                    ForgetPwd.CountdownHandler = setTimeout(ForgetPwd.countInterval, 1000);
                }
                else {
                    ForgetPwd.Countdown = 0;
                    ForgetPwd.BtnSendCaptcha.enable().vl("免费获取验证码");
                }
            },
            checkPhone: function () {
                var p = $("#txbMPhone").vl();
                if (!ForgetPwd.PhoneFormat.test(p)) {
                    $("#it-phone").vl("请输入正确的手机号码").addClass("error");
                    return false;
                }
                else {
                    $("#it-phone").removeClass("error").vl("");
                    return true;
                }
            },
            sendCaptchaEnd: function (rtn) {
                //TODO:处理发送验证码结果
                if (rtn.IsPositive) {
                    success("发送成功", "验证码已发送，5分钟内有效");
                }
                else {
                    clearTimeout(ForgetPwd.CountdownHandler);
                    ForgetPwd.BtnSendCaptcha.enable().vl("免费获取验证码");
                    $("#it-captcha").removeClass("info,success,error").addClass("error").vl(ErrFormate(res_sobiz, rtn.ErrorSrc, rtn.ErrorCode, rtn.Error));
                }
            },
            checkPwd: function () {
                var p = $("#txbPassword");
                if (p.val().length >= 6 && p.vl().indexOf(" ") == -1) {
                    $("#it-pwd").vl("").removeClass("error,info,success");
                    return true;
                } else {
                    $("#it-pwd").vl("密码至少为6位数").addClass("error");
                    return false;
                }
            },
            checkConfirmPwd: function () {
                var p = $("#txbPassword");
                var cp = $("#txbConfirmPwd");
                if (cp.vl() !== p.vl()) {
                    $("#it-confirmpwd").vl("您两次输入的密码不一致").removeClass("error,info,success").addClass("error");
                    return false;
                }
                else {
                    $("#it-confirmpwd").vl("").removeClass("error,info,success");
                    return true;
                }
            },
            resetPwd: function (ev) {
                if (ForgetPwd.checkPhone() & ForgetPwd.checkPwd() & ForgetPwd.checkConfirmPwd()) {
                    ForgetPwd.ResetPwd.pass = $("#txbConfirmPwd").vl();
                    ForgetPwd.ResetPwd.captcha = $("#txbCaptcha").vl();
                    ForgetPwd.ResetPwd.phone = $("#txbMPhone").vl();
                    $.post("/Register/ResetPwd", ForgetPwd.ResetPwd, ForgetPwd.resetPwdEnd);
                }
            },
            resetPwdEnd: function (rtn) {
                if (rtn.IsPositive) {
                    success("成功", "您的密码已重置，请使用新密码登录", 5, function () { window.location = "/Index.html"; });

                }
                else {
                    error("失败", "发生错误，未能完成密码修改操作");
                }
            }
        };
        function imgValidateEnd(rtn) {
            ForgetPwd.imgValidator = rtn;
        };

        $(function () {
            $("#vr-acnt").show();
            //元素失去焦点触发
            $("#txbMPhone").blur(ForgetPwd.checkPhone);
            $("#txbPassword").blur(ForgetPwd.checkPwd);
            $("#txbConfirmPwd").blur(ForgetPwd.checkConfirmPwd);

            ForgetPwd.BtnSendCaptcha.on("click", ForgetPwd.sendCaptcha);
            $("#txbMPhone").focus();
            $("#btnResetPwd").on("click", ForgetPwd.resetPwd);
            KeybordHelper.on($("#txbConfirmPwd"), "enter", ForgetPwd.resetPwd);

            $("#pageFoot").load("/common/pageFoot.html");
        })
    </script>

    <script>
    window.success = function (title,msg, delay, fnCallback) {
        var cnt = $("#tplPrompt>.prompt_success").clone();
        cnt.children(".p_body").children("h4").vl(title);
        cnt.children(".p_body").children("span").vl(msg);
        var p = new LiberUI.Prompt(cnt);
        p.option("Delay", delay);
        p.update();
        if (ObjHelper.IsFunc(fnCallback)) {
            p.on("disposed", fnCallback);
        }
        return p.show();

    };
    window.info = function (title,msg, delay,fnCallback) {
        var cnt = $("#tplPrompt>.prompt_info").clone();
        cnt.children(".p_body").children("h4").vl(title);
        cnt.children(".p_body").children("span").vl(msg);
        var p = new LiberUI.Prompt(cnt);
        p.option("Delay", delay);
        p.update();
        if (ObjHelper.IsFunc(fnCallback)) {
            p.on("disposed", fnCallback);
        }
        return p.show();
    };
    window.error = function (title, msg, delay, fnCallback) {
        var cnt = $("#tplPrompt>.prompt_err").clone();
        cnt.children(".p_body").children("h4").vl(title);
        cnt.children(".p_body").children("span").vl(msg);
        var p = new LiberUI.Prompt(cnt);
        p.option("Delay", delay);
        p.update();
        if (ObjHelper.IsFunc(fnCallback)) {
            p.on("disposed", fnCallback);
        }
        return p.show();
    };

    window.log = function (msg) {
        if (console) {
            console.log(msg);
        }
    };

    </script>
</body>
</html>



